<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport"
          content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <script type="text/javascript" src="../dialogs/internal.js"></script>
    <script src="../../../../lib/jquery/jquery.js"></script>
    <script src="../../../../lib/vue/vue.js"></script>
    <script src="../../../../lib/vue/vue-util.js"></script>
    <link rel="stylesheet" href="../../../css/bootstrap/css/bootstrap.css">

</head>
<body>
    <div id="app">
        <loader :name="name" ref="loader"></loader>
    </div>
</body>
</html>
<script>
    Vue.component("loader", {
        props:{
            name: String
        },
        data(){
            return {
            }
        },
        render(createElement){
            return createElement(this.name);
        }
    });

    var app = new Vue({
        el:"#app",
        created(){
            var type = this.name = getParam("type");
            loadComponent(type, "./components/" + type + ".html");

            dialog.oncancel = function () {
                if( UE.plugins[type].editdom) {
                    delete UE.plugins[type].editdom;
                }
            };
            // var node = $(UE.plugins[type].editdom);
            dialog.onok = () => {
                var nnode = $(this.$refs.loader.$children[0].$refs.preview)
                if(UE.plugins[type].editdom){
                    UE.plugins[type].editdom.outerHTML = nnode[0].innerHTML;
                    delete UE.plugins[type].editdom;
                } else {
                    editor.execCommand('insertHtml',nnode[0].innerHTML);
                }
            };
        },
        data:{
            name : ""
        }
    });
</script>